import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { SimpleGuard } from '@delon/auth';
import { environment } from '@env/environment';
// layout
import { LayoutDefaultComponent } from '../layout/default/default.component';
// import { LayoutFullScreenComponent } from '../layout/fullscreen/fullscreen.component';
// import { LayoutPassportComponent } from '../layout/passport/passport.component';
// dashboard pages
import { DashboardComponent } from './dashboard/dashboard.component';
// passport pages
// import { UserLoginComponent } from './passport/login/login.component';
// import { UserRegisterComponent } from './passport/register/register.component';
// import { UserRegisterResultComponent } from './passport/register-result/register-result.component';
// single pages
import { CallbackComponent } from './callback/callback.component';
// import { UserLockComponent } from './passport/lock/lock.component';
import { LoginComponent } from './login/login.component';

const routes: Routes = [
  {
    path: '',
    component: LayoutDefaultComponent,
    canActivate: [SimpleGuard],
    children: [
      { path: '', redirectTo: 'dashboard', pathMatch: 'full' },
      { path: 'dashboard', component: DashboardComponent, data: { title: '首页' } },
      { path: 'exception', loadChildren: () => import('./exception/exception.module').then(m => m.ExceptionModule) },
      // 业务子模块
      { path: 'icm-global', loadChildren: './main/icm-global/global.module#GlobalModule' },
      { path: 'icm-base', loadChildren: './main/icm-base/base.module#BaseModule' },
      { path: 'icm-system-user', loadChildren: './main/icm-system-user/system-user.module#SystemUserModule' },
      {
        path: 'icm-study-schedule',
        loadChildren: './main/icm-study-schedule/study-schedule.module#StudyScheduleModule',
      },
      {
        path: 'icm-student-academic',
        loadChildren: './main/icm-student-academic/student-academic.module#StudentAcademicModule',
      },
      {
        path: 'icm-student-status',
        loadChildren: './main/icm-student-status/student-status.module#StudentStatusModule',
      },
    ],
  },
  // 全屏布局
  // {
  //     path: 'fullscreen',
  //     component: LayoutFullScreenComponent,
  //     children: [
  //     ]
  // },
  // passport
  // {
  //   path: 'passport',
  //   component: LayoutPassportComponent,
  //   children: [
  //     { path: 'login', component: UserLoginComponent, data: { title: '登录', titleI18n: 'pro-login' } },
  //     { path: 'register', component: UserRegisterComponent, data: { title: '注册', titleI18n: 'pro-register' } },
  //     {
  //       path: 'register-result',
  //       component: UserRegisterResultComponent,
  //       data: { title: '注册结果', titleI18n: 'pro-register-result' },
  //     },
  //     { path: 'lock', component: UserLockComponent, data: { title: '锁屏', titleI18n: 'lock' } },
  //   ],
  // },
  // 单页不包裹Layout
  { path: 'login', component: LoginComponent, data: { title: '登录' } },
  { path: 'callback/:type', component: CallbackComponent },
  { path: '**', redirectTo: 'exception/404' },
];

@NgModule({
  imports: [
    RouterModule.forRoot(routes, {
      useHash: environment.useHash,
      enableTracing: false,
      // NOTICE: If you use `reuse-tab` component and turn on keepingScroll you can set to `disabled`
      // Pls refer to https://ng-alain.com/components/reuse-tab
      scrollPositionRestoration: 'top',
    }),
  ],
  exports: [RouterModule],
})
export class RouteRoutingModule {}
